package com.cy.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.jt.dubbo.pojo.User;
import com.jt.dubbo.service.UserService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class UserController {
    /**
     * check:true 检查是否有消费的提供者
     * 先启动服务提供者,之后启动消费者
     */
    @Reference(timeout = 3000,check = true)
    private UserService userService;

    @RequestMapping("/findAll")
    public List<User> findAll(){
        return userService.findAll();
    }
    @RequestMapping("/saveUser/{name}/{age}/{sex}")
    public String savaUser(User user){
        userService.saveUser(user);
        return "用户入库成功!!!";
    }

}
